<script>
import { mapState, mapActions } from "vuex";
export default {
  computed: {
    ...mapState("food", ["food_car", "food_money", "food_number"]),
    ...mapState("shop", ["shop_car", "shop_money", "shop_number"]),
  },
  data() {
    return {
      info: {
        url: "./static/img/icon_horn_margin.png",
        url: "./static/img/icon_horn.png",
      },
    };
  },
  onLoad(option) {
    console.log("option", option);
  },
  onLaunch: function () {
    console.log("App Launch");

    uni.getSystemInfo({
      success(res) {
        console.log("sss", res);
        uni.setStorageSync("systemInfo", res);

        const { statusBarHeight, screenHeight } = res;
        let statusHeight = statusBarHeight / (uni.upx2px(100) / 100); // 状态栏高度
        let height = screenHeight / (uni.upx2px(100) / 100); //屏幕高度
        let map_height = height - (statusHeight + 100 + 80);

        uni.setStorageSync("map_height", map_height); //其他页面使用的高度

        let toprpx = statusHeight + 80 + 20; // 100为 header 20 为间距
        uni.setStorageSync("toprpx", toprpx);
      },
    });
  },
  globalData: {
    test: "",
    pageQuery: {},
  },
  onShow: function (options) {
    console.log("App Show 1");
    // 获取缓存中的 购物车数据 对vuex赋值
    let food_car = uni.getStorageSync("set_init_food_shop_car");
    this.set_init_food_shop_car(food_car);
    let shop_car = uni.getStorageSync("set_init_shop_shop_car");
    this.set_init_shop_shop_car(shop_car);
    this.set_change_is_login && this.set_change_is_login();
    console.log("App Show 2");
    this.globalData.pageQuery = options.query; //获取进入小程序的参数
  },
  onHide: function () {
    console.log("App Hide 1");
  },
  methods: {
    ...mapActions("food", ["set_init_food_shop_car"]),
    ...mapActions("shop", ["set_init_shop_shop_car"]),
    ...mapActions("user", ["set_change_is_login"]),
  },
};
</script>

<style>
/*每个页面公共css */
/* page{
		 min-height: 100vh;
		  background-color: #007AFF;
	} */
@import url("./static/css/free.css");
@import url("./static/css/public.css");

view,
image,
text {
  box-sizing: border-box;
  font-weight: 400;
}
page {
  background: #f2f2f2;
  height: 100%;
  /* background-color: #F1F1F1; */
}
image {
  display: block;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
